package com.jrx.anytxn.param.service.merge.impl;

import com.jrx.anytxn.param.entity.TlMergeBillingDetlLog;
import com.jrx.anytxn.param.entity.TlMergeBillingSummaryLog;
import com.jrx.anytxn.param.mapper.base.TlMergeBillingDetlLogMapper;
import com.jrx.anytxn.param.mapper.base.TlMergeBillingSummaryLogMapper;
import com.jrx.anytxn.param.service.merge.IMergeBillingLogService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @program: anytxn-cf-parent
 * @description:
 * @author: xiaoyu.jing
 * @date: 2020-11-07 19:10
 **/
@Service
public class MergeBillingLogServiceImpl implements IMergeBillingLogService {

    @Resource
    private TlMergeBillingSummaryLogMapper tlMergeBillingSummaryLogMapper;

    @Resource
    private TlMergeBillingDetlLogMapper tlMergeBillingDetlLogMapper;

    @Transactional(propagation = Propagation.REQUIRES_NEW,rollbackFor = Exception.class)
    @Override
    public void saveSummaryLog(TlMergeBillingSummaryLog log) {
        tlMergeBillingSummaryLogMapper.insertSelective(log);
    }

    @Transactional(propagation = Propagation.REQUIRES_NEW,rollbackFor = Exception.class)
    @Override
    public void saveDetlLogList(List<TlMergeBillingDetlLog> logList) {
        for(TlMergeBillingDetlLog detlLog : logList){
            tlMergeBillingDetlLogMapper.insertSelective(detlLog);
        }
    }


    @Transactional(propagation = Propagation.REQUIRES_NEW,rollbackFor = Exception.class)
    @Override
    public void updateSummaryLog(TlMergeBillingSummaryLog log) {
        tlMergeBillingSummaryLogMapper.updateByPrimaryKeySelective(log);
    }

    @Transactional(propagation = Propagation.REQUIRES_NEW,rollbackFor = Exception.class)
    @Override
    public void updateDetlLogList(List<TlMergeBillingDetlLog> logList) {
        for(TlMergeBillingDetlLog detlLog : logList){
            tlMergeBillingDetlLogMapper.updateByPrimaryKeySelective(detlLog);
        }
    }

}
